package com.lancoo.znbkxx.teacher.adapter

import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.Paper
import kotlinx.android.synthetic.main.item_search_list.view.*

/**
 * @author : Admin
 * @date   : 2019/8/1 8:45
 * @desc   :
 */
class SearchListAdapter(layoutResId: Int, data: MutableList<Paper>?) :
        BaseQuickAdapter<Paper, BaseViewHolder>(layoutResId, data) {
    override fun convert(helper: BaseViewHolder, item: Paper?) {
        helper.itemView.tv_item.text = item!!.PaperName
        val matrix = ColorMatrix()
        matrix.setSaturation(0f)
        val filter = ColorMatrixColorFilter(matrix)
        helper.itemView.iv_item.colorFilter = filter
        when (item.Layer) {
            0, 1, 2 -> helper.itemView.iv_item.setImageResource(R.mipmap.icon_paper_section_basic)
            3 -> helper.itemView.iv_item.setImageResource(R.mipmap.icon_paper_section_textbook)
            4 -> helper.itemView.iv_item.setImageResource(R.mipmap.icon_paper_section_topic)
        }
    }
}